home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 72 / IOPROG_72.ISO / soft / Codice / CRobots / Codice Robot anni precedenti / CR2-SRC.ZIP / SP.R < prev    next >
Encoding:
Text File  |  1992-09-27  |  3.7 KB  |  200 lines

  1. /* SP.r, crobot da combattimento
  2.    Autore:Filippo Quondam, via G.B. De Rossi 31, 00161 Roma
  3. */
  4. int    r, s, ang, ag;
  5. main()  
  6. {
  7.  
  8. ang:
  9.      = 0;
  10.     while (1) {
  11.  
  12.         while (loc_x() > 200) {                /* lato sud */
  13.             drive(180, 100);
  14.  
  15.             s = 701;
  16.  
  17.             while ( (s > 700) && (loc_x() > 230)) {
  18.                 while (scan(ang, 10) < 40)         /*1^ ciclo di scan */
  19.                     ang += 18;
  20.                 ang += 355;
  21.                 if (!(s = scan(ang, 6))) {
  22.                     ang += 10; /* 2^ ciclo di scan */
  23.                     if ((s = scan(ang, 6)) < 40) 
  24.                         s = 701;
  25.                 }
  26.             }
  27.  
  28.             spara();                          /*chiama la procedura*/
  29.             ang += 325 + r / 35;                    /*retrocede ang per lo scan successivo */
  30.  
  31.         }
  32.  
  33.         drive(180, 0);                          /*spegne il motore*/
  34.         while (speed() > 52)                     /*aspetta che si rallenti*/
  35.             while (((scan(ang, 10)) < 10) && (speed() > 56))
  36.                 ang += 18;             /*frattempo si cerca con lo scan....*/
  37.  
  38.  
  39.         while (loc_y() < 800) {                /* lato ovest */
  40.             drive(90, 100);
  41.             s = 701;
  42.             while ( (s > 700) && (loc_y() < 770)) {
  43.                 while ((scan(ang, 10)) < 40)
  44.                     ang += 18;
  45.                 ang += 355;
  46.                 if (!(s = scan(ang, 6))) {
  47.                     ang += 10;
  48.                     if ((s = scan(ang, 6)) < 40) 
  49.                         s = 701;
  50.                 }
  51.             }
  52.             spara();
  53.             ang += 325 + r / 35;
  54.  
  55.         }
  56.  
  57.         drive(90, 0);
  58.         while (speed() > 52)
  59.             while (((scan(ang, 10)) < 10) && (speed() > 56))
  60.                 ang += 18;
  61.  
  62.         while (loc_x() < 800) {                  /* lato nord */
  63.             drive(0, 100);
  64.             s = 701;
  65.             while ( (s > 700) && (loc_x() < 770)) {
  66.                 while ((scan(ang, 10)) < 40)
  67.                     ang += 18;
  68.                 ang += 355;
  69.                 if (!(s = scan(ang, 6))) {
  70.                     ang += 10;
  71.                     if ((s = scan(ang, 6)) < 40) 
  72.                         s = 701;
  73.                 }
  74.             }
  75.             spara();
  76.             ang += 325 + r / 35;
  77.  
  78.         }
  79.  
  80.         drive(0, 0);
  81.         while (speed() > 52)
  82.             while (((scan(ang, 10)) < 10) && (speed() > 56))
  83.                 ang += 18;
  84.  
  85.  
  86.         while (loc_y() > 200) {                   /* lato est */
  87.             drive(270, 100);
  88.             s = 701;
  89.             while ((s > 700) && (loc_y() > 230)) {
  90.                 while ((scan(ang, 10)) < 40)
  91.                     ang += 18;
  92.                 ang += 355;
  93.                 if (!(s = scan(ang, 6))) {
  94.                     ang += 10;
  95.                     if ((s = scan(ang, 6)) < 40) 
  96.                         s = 701;
  97.                 }
  98.             }
  99.  
  100.             spara();
  101.             ang += 325 + r / 35;
  102.         }
  103.  
  104.         drive(270, 0);
  105.         while (speed() > 52)
  106.             while (((scan(ang, 10)) < 10) && (speed() > 56))
  107.                 ang += 18;
  108.     }
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. spara()                         /* procedura spara */
  117. {
  118.     if (s < 180) 
  119.         cannon(ang, s);       /* se siamo vicini, spara! */
  120.     else
  121.      {
  122.         ang += 350;    /* 3^ livello di scan */
  123.         /*350*/     if (scan(ang, 3) > 10);
  124. else
  125. {
  126.     ang += 5;
  127.     /*355*/         if (scan(ang, 3) > 10)
  128.         ;
  129.     else
  130.      {
  131.         ang += 5;
  132.         /*360*/         if (scan(ang, 3) > 10)
  133.             ;
  134.         else
  135.          {
  136.             ang += 5;
  137.             /*365*/           if (scan(ang, 3) > 10)
  138.                 ;
  139.             else
  140.              {
  141.                 ang += 5;
  142.                 /*370*/           if (scan(ang, 3) > 10)
  143.                     ;
  144.             }
  145.         }
  146.     }
  147. }
  148.  
  149.  
  150. s = scan(ang, 6);
  151. ag = ang + 352;          /* 4^ livello di scan */
  152. /*352*/     if (scan(ag, 2)
  153.  > 10);
  154. else
  155. {
  156.     ag += 4;
  157.     /*356*/         if (scan(ag, 2) > 10)
  158.         ;
  159.     else
  160.      {
  161.         ag += 4;
  162.         /*360*/         if (scan(ag, 2) > 10)
  163.             ;
  164.         else
  165.          {
  166.             ag += 4;
  167.             /*364*/           if (scan(ag, 2) > 10)
  168.                 ;
  169.             else
  170.              {
  171.                 ag += 4;
  172.                 /*368*/           if (scan(ag, 2) > 10)
  173.                     ;
  174.             }
  175.         }
  176.     }
  177. }
  178.  
  179.  
  180. if (((ag-ang + 722)
  181.  % 360)
  182.  < 50) 
  183. ang = 4 + ag-ang;
  184. else 
  185.     ang = 356 + ag - ang; /* decide l'angolo
  186.        correttore prevedendo la direzione avversaria;722 serve per
  187.        correggere l'avvistamento secondo il movimento di SP;*/
  188.  
  189. if ((r = scan(ag, 8)
  190. )
  191.  > 80)
  192. cannon(ag + ang + 3, r + 36*(r-s)
  193.  / 25); /* spara,
  194.        correggendo la direzione di SP (il +3), e il range */
  195. ang = ag + ang;
  196.     }
  197. }
  198.  
  199.  
  200.